home *** CD-ROM | disk | FTP | other *** search
- /*
- GETimer.h
-
- Graphic Elements timer functions
-
- Copyright 1995 by Al Evans. All rights reserved.
-
- 11/1/95
-
- */
-
- #ifndef GETIMER
-
- #define GETIMER
-
- #ifndef PRELOAD
- #include "preload.h"
- #endif
-
- #ifndef GEDEFS
- #include "Defs.h"
- #endif
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- //Timer "rate" for 1 ms world time/ms real time
- #define geTimerStdRate 0x00010000
-
- /*
- The variable-rate timer for a GEWorld
- */
-
- #if defined(COMPILER_IS_MAC)
- // Use Time Manager for Mac
- #include <timer.h>
- #endif
-
- #if defined(TARGET_IS_WIN95)
- // Use MultiMedia timer for Windows 95
- #include <MMSYSTEM.H>
- typedef struct {
- MMRESULT taskRef;
- volatile Boolean inTask;
- } TMTask;
-
- // Windows only -- called before using any GE services
- Boolean InitGETimer();
- // Windows only -- called after app is finished with GE
- void ShutdownGETimer();
- #endif
-
- #if defined(TARGET_IS_BEOS)
- typedef struct {
- thread_id thread;
- volatile bool quit;
- volatile bool finished;
- } TMTask;
-
- extern sem_id winLockerSemaphore;
-
- // Statistics gathering for BeOS
- double GetLastFrameTime();
- ulong GetTotalFrames();
- double GetTotalFrameTime();
-
- // Utility functions
- bool LockWorldWindow(GEWorldPtr world);
- void UnlockWorldWindow(GEWorldPtr world);
-
- #endif
-
- // Basic time slice is 4 ms
- #define geTimeTick 4
-
- // Timer "rate" for 1 ms world time/ms real time
- #define geTimerStdRate 0x00010000
-
- // Timer record for GEWorld
- typedef struct GETMgrRec {
- TMTask aTMTask;
- unsigned long currentTime;
- long currentRate;
- long timeAccum;
- Boolean running;
- } GETMgrRec, *GETMgrRecPtr;
-
- // Function prototypes -- these are defined in GETimer.c for Mac and GEWTimer.c for Windows
-
- // For completeness
- GETMgrRecPtr NewGETimer(void);
-
- // Free system services and memory
- void DisposeGETimer(GEWorldPtr world);
-
- void StartGETimer(GEWorldPtr world);
-
- void StopGETimer(GEWorldPtr world);
-
-
- //Returns current time in world
- unsigned long CurrentGETime(GEWorldPtr world);
-
- /* Set the number of timer milliseconds that pass per "real"
- millisecond. newRate is treated as a fixed-point number,
- with a two-byte positive integer and a two byte fraction,
- such that a value of 0x00010000 will give a 1-to-1
- correspondence between Graphic Elements "milliseconds"
- and real milliseconds.
- */
-
- void SetGETimerRate(GEWorldPtr world, unsigned long newRate);
-
- // Returns current "rate" of timer in world
- unsigned long GetGETimerRate(GEWorldPtr world);
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif // GETIMER
-